//
//  DevSocketManage.h
//  RuiHeApp
//
//  Created by Jun on 2022/11/30.
//
typedef NS_ENUM(NSInteger,DevSocketState) {
    DevSocketStateDisconnect = 0,
    DevSocketStateConnecting,
    DevSocketStateConnected
};

#import <Foundation/Foundation.h>

@class GCDAsyncSocket;
NS_ASSUME_NONNULL_BEGIN
@protocol DevSocketProtocal <NSObject>
@optional
- (void)DevSocket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port;

- (void)DevSocketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err;

- (void)DevSocket:(GCDAsyncSocket *)sock didReceiveData:(NSString *)data withTag:(long)tag;
@end


@interface DevSocketManage : NSObject

//是否需要更新DevId
@property (nonatomic ,assign) BOOL isNeedUpdate;
//设备Id
@property (nonatomic ,copy) NSString *devId;

@property (nonatomic ,weak) id<DevSocketProtocal> delegate;

//连接状态
@property (nonatomic, assign) DevSocketState socketState;

+ (DevSocketManage *)shareSocketManage;

//连接服务端
- (void)connectToHost:(NSString *)host onPort:(NSInteger)port result:(void(^)(BOOL isConnect))block;
//断开连接
- (void)disconnect;
//发送数据
- (void)sendMessage:(NSString *)msge;


@end

NS_ASSUME_NONNULL_END
